<?php
namespace system\core;

/**
 * Registry
 *
 * @author Steffen Brem <steffenbrem@gmail.com>
 * @package System.core
 */
class Registry 
{
    /**
     * Memory of the application
     * 
     * @var array
     */
    public static $_memory = array();
    
    /**
     * Memory of the system
     * 
     * @var array
     */
    private static $_systemMemory = array();
    
    /**
     * Set something in the memory
     * 
     * @access public
     * @param  string  $item
     * @param  mixed   $value
     */
    public static function set( $index, $value, $system = FALSE )
    {
        if ( $system === TRUE )
        {
            self::$_systemMemory[$index] = $value;
            return;
        }
        
        self::$_memory[$index] = $value;
    }
    
    /**
     * Get data from memory
     * 
     * @access public
     * @param string $item
     * @return mixed
     */
    public static function get( $index, $system = FALSE )
    {
        if ( $system === TRUE ) 
        {
            if ( ! isset(self::$_systemMemory[$index]) ) { return FALSE; }
            
            return self::$_systemMemory[$index];
        }
        
        if ( ! isset(self::$_memory[$index]) ) { return FALSE; }
            
        return self::$_memory[$index];
    }
    
}